//页面加载完成
$(function () {


    var  lossItem_datagrid =  $("#lossItem_datagrid");

    var searchBox=$("#searchBox");

    searchBox.searchbox({
        searcher:function(value,name){
            lossItem_datagrid.datagrid("load",{keyword:value});
        },
        prompt:'关键字'
    });

    //初始员工列表界面
   lossItem_datagrid.datagrid({
        fit: true,
        fitColumns: true,
        striped: true,
        url: '/lossItem/list',
        rownumbers: true,
        pagination: true,
        singleSelect: true,
        columns: [[
            {field: 'id', hidden: true},
            {field: 'casesTime', title: '发生时间', width: 100},
            {field: 'lossAddress', title: '事故地点', width: 100},
            {field: 'casesEmpName', title: '接通员工', width: 100},
            {field: 'accidentTime', title: '处理时间', width: 100},
            {field: 'accidentEmpName', title: '处理员工', width: 100},
            {field: 'carName', title: '车名', width: 100},
            {field: 'ownerName', title: '车主', width: 100},
            {field: 'policySn', title: '保单编号', width: 100},
            {field: 'policyName', title: '保单种类', width: 100},
            {field: 'casesDescription', title: '事故描述', width: 100},
            {field: 'responsibility', title: '责任认定', width: 100},
            {field: 'totalNumber', title: '总数量', width: 100},
            {field: 'totalAccount', title: '总金额', width: 100},
            {field: 'bankcard', title: '卡号', width: 100},
            {field: 'policyCompany', title: '保险公司', width: 100}

        ]],
        toolbar: "#tb"
    })
        //将方法绑定到对象中
        var cmdObj = {

            reloadAccident:function () {
                lossItem_datagrid.datagrid("reload");
            }

        }
        //使用js来绑定事件  使用了属性过滤器来完成该操作
    $("a[data-cmd]").click(function(){
        var cmd = $(this).data("cmd");
        //调用方法
        cmdObj[cmd]();
    });


})
//发送邮件
function mailsome1() {
    $.messager.prompt('', '请输入收件人邮箱:', function(who){
        if (who){
            $.messager.prompt('', '输入主题:', function(what){
                if (what){
                    $.messager.confirm('', "你确定要向" + who + "发送主题为 " + what + "的邮件么?", function(r){
                        if (r){
                            parent.location.href = 'mailto:' + who + '?subject=' + what + '';
                        }
                    });
                }
            });
        }
    });
}